/*
 * INSANE - Interactive Structural Analysis Environment
 *
 * Copyright (C) 2003-2006
 * Universidade Federal de Minas Gerais
 * Escola de Engenharia
 * Departamento de Engenharia de Estruturas
 *
 * Author's email :     insane@dees.ufmg.br
 * Author's Website :   http://www.dees.ufmg.br/insane
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
 
package br.ufmg.dees.insane.draw;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.util.Vector;

/**
 * @author Fonseca, Flavio & Pitangueira, Roque
 * @since	April 2004
 */
public abstract class SupportDraw extends Draw {
    
//*****************************************************************************
//*****************************************************************************
	
    public static class XYZ extends SupportDraw {
        
        public XYZ() {
            this(new Point(0, 0), 0);
        }
		
	//*****************************************************************************
		
        public XYZ(Point loc) {
            this(loc, 0);
        }
        
	//*****************************************************************************
		
        public XYZ(Point loc, double theta) {
            this(loc, theta, null);
        }
        
	//*****************************************************************************
		
        public XYZ(Point loc, double theta, Object represents) {
            this.setLocation(loc);
            this.setAngle(theta);
            this.setRepresents(represents);
            this.setSize(new Dimension(4, 32));
        }
        
	//*****************************************************************************
		
        public Vector<Object> getShapes() {
            
            Vector<Object> shapes = new Vector<Object>();
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
            
            double H = height * scale;
            double h = width * scale;
            
            shapes.add(new Line2D.Double(x, y + H/2, x, y - H/2));
            
            for(int i = 0; i < H/h ; i++)
                shapes.add(new Line2D.Double(x - h, y - H/2 + i*h, x, y - H/2 + ((i + 1) * h)));
            
            return shapes;
        }
        
	//*****************************************************************************
		
        /**
         * Returns the draw bounds in device units.
         *
         * @return the draw bounds
         */
        public Rectangle getBounds() {
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
			
            int W = (int)(width * scale);
            int H = (int)(height * scale);
            return new Rectangle(x - W - 1, y - H/2 - 1, W + 1, H + 1);
        }
        
    }
    
//*****************************************************************************
//*****************************************************************************
	
    public static class XY extends SupportDraw {
         
        public XY() {
            this(new Point(0, 0), 0);
        }
        
	//*****************************************************************************
		
        public XY(Point loc) {
            this(loc, 0);
        }
        
	//*****************************************************************************
		
        public XY(Point loc, double theta) {
            this(loc, theta, null);
        }
        
	//*****************************************************************************
		
        public XY(Point loc, double theta, Object represents) {
            this.setLocation(loc);
            this.setAngle(theta);
            this.setRepresents(represents);
            this.setSize(new Dimension(32,24));
        }
        
	//*****************************************************************************
		
        public Vector<Object> getShapes() {
            
            Vector<Object> shapes = new Vector<Object>();
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
            
            double H = height * scale;
            double h = height/6 * scale;
            double W = width * scale;
            
            shapes.add(new Line2D.Double(x - (W/2), y + H - h, x + (W/2), y + H - h ) );
            shapes.add(new Line2D.Double(x, y, x + (2.5*h), y + (5*h) ) );
            shapes.add(new Line2D.Double(x, y, x - (2.5*h), y + (5*h) ) );
            
            for(int i = 0; i <= H/h + 1 ; i++)
                shapes.add( new Line2D.Double(x - (W/2) + (i*h), y + H, x - (W/2) + h * (i+1), y + H - h ) );
            
            return shapes;
        }
        
	//*****************************************************************************
		
        /**
         * Returns the draw bounds in device units.
         *
         * @return the draw bounds
         */
        public Rectangle getBounds() {
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
			
            int W = (int)(width * scale);
            int H = (int)(height * scale);
            return new Rectangle((int)(x - W/2), y, W, H);
        }
        
    }
    
//*****************************************************************************
//*****************************************************************************
	
    public static class YZ extends SupportDraw {
        
        public YZ() {
            this(new Point(0, 0), 0);
        }
		
	//*****************************************************************************
		
        public YZ(Point loc) {
            this(loc, 0);
        }
        
	//*****************************************************************************
		
        public YZ(Point loc, double theta) {
            this(loc, theta, null);
        }
        
	//*****************************************************************************
		
        public YZ(Point loc, double theta, Object represents) {
            this.setLocation(loc);
            this.setAngle(theta);
            this.setRepresents(represents);
            this.setSize(new Dimension(32, 4));
        }
        
	//*****************************************************************************
		
        public Vector<Object> getShapes() {
            
            Vector<Object> shapes = new Vector<Object>();
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
            
            double H = height * scale;
            double W = width * scale;
            
            shapes.add( new Line2D.Double(x - (W/2), y, x + (W/2), y));
            shapes.add( new Line2D.Double(x - (W/2), y + H, x + (W/2), y + H));
            shapes.add( new Ellipse2D.Double(x - (3*H), y, H, H));
            shapes.add( new Ellipse2D.Double(x + (2*H), y, H, H));
            shapes.add( new Ellipse2D.Double(x - (0.5*H), y, H, H));
            
            for(int i = 0; i <= W/H - 1; i++)
                shapes.add( new Line2D.Double(x - (W/2) + (i*H), y + (2*H), x - (W/2) + H * (i+1), y + H));
            
            return shapes;
        }
        
	//*****************************************************************************
		
        /**
         * Returns the draw bounds in device units.
         *
         * @return the draw bounds
         */
        public Rectangle getBounds() {
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
			
            int W = (int)(width * scale);
            int H = (int)(height * scale);
            return new Rectangle((int)(x - W/2 - 1), y -1, W + 1, H*2 +1);
        }
        
    }
    
//*****************************************************************************
//*****************************************************************************
	
    public static class Y extends SupportDraw {
         
        public Y() {
            this(new Point(0, 0), 0);
        }
        
	//*****************************************************************************
		
        public Y(Point loc) {
            this(loc, 0);
        }
        
	//*****************************************************************************
		
        public Y(Point loc, double theta) {
            this(loc, theta, null);
        }
        
	//*****************************************************************************
		
        public Y(Point loc, double theta, Object represents) {
            this.setLocation(loc);
            this.setAngle(theta);
            this.setRepresents(represents);
            this.setSize(new Dimension(32, 24));
        }
        
	//*****************************************************************************
		
        public Vector<Object> getShapes() {
            
            Vector<Object> shapes = new Vector<Object>();
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
            
            double H = height * scale;
            double h = height/6 * scale;
            double W = width * scale;
            
            shapes.add(new Line2D.Double(x - (W/2), y + H, x + (W/2), y + H ) );
            shapes.add(new Line2D.Double(x - (W/2), y + H - h, x + (W/2), y + H - h ) );
            shapes.add(new Line2D.Double(x, y, x + (2.5*h), y + (5*h) ) );
            shapes.add(new Line2D.Double(x, y, x - (2.5*h), y + (5*h) ) );
            shapes.add(new Ellipse2D.Double(x - (3*h), y + (5*h), h, h) );
            shapes.add(new Ellipse2D.Double(x + (2*h), y + (5*h), h, h) );
            shapes.add(new Ellipse2D.Double(x - (0.5*h), y + (5*h), h, h) );
            
            for(int i = 0; i <= H/h + 1 ; i++)
                shapes.add( new Line2D.Double(x - (W/2) + (i*h), y + H + h, x - (W/2) + h * (i+1), y + H));
            
            return shapes;
        }
        
	//*****************************************************************************
		
        /**
         * Returns the draw bounds in device units.
         *
         * @return the draw bounds
         */
        public Rectangle getBounds() {
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
			
            int W = (int)(width * scale);
            int H = (int)(width * scale);
            int h = (int)(height/6 * scale);
            return new Rectangle((int)(x - W/2), y, W, H - h);
        }
        
    }

//*****************************************************************************
//*****************************************************************************
	
	public static class Z extends SupportDraw {
        
        public Z() {
            this(new Point(0, 0), 0);
        }
		
	//*****************************************************************************
		
        public Z(Point loc) {
            this(loc, 0);
        }
        
	//*****************************************************************************
		
        public Z(Point loc, double theta) {
            this(loc, theta, null);
        }
        
	//*****************************************************************************
		
        public Z(Point loc, double theta, Object represents) {
            this.setLocation(loc);
            this.setAngle(theta);
            this.setRepresents(represents);
            this.setSize(new Dimension(4, 32));
        }
        
	//*****************************************************************************
		
        public Vector<Object> getShapes() {
            
            Vector<Object> shapes = new Vector<Object>();
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int height = this.getSize().height;
            double scale = this.getScale();
            
            double H = height * scale;
            
            shapes.add(new Line2D.Double(x-H/2, y+H/2, x+H/2, y+H/2));
			shapes.add(new Line2D.Double(x+H/2, y+H/2, x+H/2, y-H/2));
			shapes.add(new Line2D.Double(x+H/2, y-H/2, x-H/2, y-H/2));
			shapes.add(new Line2D.Double(x-H/2, y-H/2, x-H/2, y+H/2));
			
            return shapes;
        }
        
	//*****************************************************************************
		
        /**
         * Returns the draw bounds in device units.
         *
         * @return the draw bounds
         */
        public Rectangle getBounds() {
            
            int x = this.getLocation().x;
            int y = this.getLocation().y;
            int width = this.getSize().width;
            int height = this.getSize().height;
            double scale = this.getScale();
			
            int W = (int)(width * scale);
            int H = (int)(height * scale);
            return new Rectangle(x - W - 1, y - H/2 - 1, W + 1, H + 1);
        }
        
    }
	
//*****************************************************************************
//*****************************************************************************
}
